package com.kfm.am;

public class Kfm {

    static String user = "kfm";
    static String pass = "123456";

    public static void login(String username, String password) throws Exception {
        if (username == null || username.isEmpty()) {
            Exception e = new RuntimeException("用户名不能为空");
            throw e;
//            throw new RuntimeException("用户名不能为空");
        }
        if (password == null || password.isEmpty()) {
            throw new RuntimeException("密码不能为空");
        }
        if (!(username.equals(user) && password.equals(pass))) {
            throw new Exception("登录失败，用户名或密码错误");
        }
        System.out.println("登录成功！");
    }

    public static void main(String[] args) {
        try {
            login("kfm", "123");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}

